Feature/idaas 805/tenants client alternative#617
Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a Catalog client and significantly expands the LicenseManager client with binding management capabilities. The LicenseManager has been refactored from a single file into a modular directory structure with separate type definitions, and new methods for creating, reading, updating, and deleting tenant bindings have been added.
Key changes:
- Added a new Catalog client with sales channel retrieval functionality
- Expanded LicenseManager with CRUD operations for tenant bindings
- Refactored LicenseManager into a modular directory structure with dedicated type definitions
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/clients/janus/index.ts | Exports the new Catalog client |
| src/clients/janus/LicenseManager/types.ts | Defines TypeScript interfaces for binding operations and API request/response structures |
| src/clients/janus/LicenseManager/index.ts | Implements the refactored LicenseManager with new binding management methods |
| src/clients/janus/LicenseManager.ts | Removes the old single-file LicenseManager implementation |
| src/clients/janus/Catalog/types.ts | Defines the SalesChannel interface for catalog operations |
| src/clients/janus/Catalog/index.ts | Implements the Catalog client with sales channel retrieval |
| src/clients/IOClients.ts | Adds getter for the new Catalog client and updates LicenseManager import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
24029f8 to
299a391
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of this pull request?
Add LM and Catalog client methods to enable applications to replace requests to the Tenants systems (the
Tenantsclient should be marked as deprecated from now on).The new API client methods reflect the API interface directly, without converting data or applying business logic. Therefore, any code that depends on the Tenants client or API should adapt to the new data structure interface.
Data fetch and CRUD operations should be replaced like this:
/api/tenant/bindingsroutes should use/api/license-manager/bindingroutes instead (you can use this PR's new client methods as reference)./api/tenant/tenantsroute should be replaced by inferred data or data sought from different places:idandmetadataproperties returned from the Tenants client were incorrectly typed, because the API did not actually return these fields.slugandtitlecorrespond to the requestedtenantname.editionandinfrafields, but I found out that these fields are mostly hard-coded by the Tenants system to return'vtex:tier-1339'and'VTEX'.bindingsfield should be sought from the License Manager API:/api/license-manager/binding/site/{tenant}. In the new client, you should usecontext.clients.licenseManager.listBindings({ tenant, adminUserAuthToken })instead (more details below).defaultCurrencyanddefaultLocalefields should be sought from the Tenant's first sales channel, from the Catalog API:/api/catalog_system/pub/saleschannel/1. In the new client, you should usecontext.clients.catalog.getSalesChannel(1)(more details below).Result from Tenants client should be replaced like this:
defaultLocale->CultureInfofromcontext.clients.catalog.getSalesChannel(1).defaultCurrency->CurrencyCodefromcontext.clients.catalog.getSalesChannel(1).bindings[x].id->Idfromcontext.clients.licenseManager.listBindings().bindings[x].canonicalBaseAddress-> result of concatenation:`${Addresses[i].Host}/${Addresses[i].BasePath}`bindings[x].alternateBaseAddresses-> list with concatenation results:`${Addresses[i].Host}/${Addresses[i].BasePath}`bindings[x].defaultLocale->DefaultLocalefromcontext.clients.licenseManager.listBindings().bindings[x].supportedLocales-> fromSupportedLocalesfromcontext.clients.licenseManager.listBindings().bindings[x].defaultCurrency->CurrencyCodefromcontext.clients.catalog.getSalesChannel(1).bindings[x].supportedCurrencies-> I (@rafarubim) am uncertain of a replacement, but[CurrencyCode]seems acceptable.bindings[x].extraContext-> I (@rafarubim) am uncertain of a replacement, but I believe it could be related toDefaultSalesChannelIdfromcontext.clients.licenseManager.listBindings().bindings[x].targetProduct-> This value should be inferred from thebindings[x].canonicalBaseAddressandbindings[x].alternateBaseAddressesfields, following this logic:How should this be manually tested?
This PR's changes have been locally linked, then have been added to a test branch in the vtex/auth-admin repository.
This branch adds GraphQL queries and server resolvers that correspond to a
node-vtex-apiclient call, like this:graphql/schema.graphqlnode/index.tsTo test these GraphQL queries, go into this GraphiQL workspace.
You can check out the following queries/mutations to test the application:
Get Sales Channel

List Bindings

Get Binding

Create Binding
Delete Binding
Update Binding
Types of changes